package com.xnyzc.lhy.order.controller.version;

import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.order.entity.param.app.AddAppVersionParam;
import com.xnyzc.lhy.order.entity.param.cms.PageDto;
import com.xnyzc.lhy.order.service.version.AppVersionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 用户APP版本检查更新
 * </p>
 *
 * @author conglijuan
 * @since 2019-10-14
 */
@RestController
@RequestMapping("/version")
public class AppVersionController {

    @Autowired
    private AppVersionService appVersionService;

    /**
     * 新增app版本信息
     *
     * @return
     */
    @ApiOperation(value = "新增app版本信息", notes = "新增app版本信息")
    @PostMapping(value = "addAppVersion")
    public Rv addAppVersion(@RequestBody AddAppVersionParam param) {
        return appVersionService.addAppVersion(param);
    }

    /**
     * 获取所有app版本信息
     *
     * @return
     */
    @ApiOperation(value = "获取所有app版本信息", notes = "获取所有app版本信息")
    @PostMapping(value = "getAppVersions")
    public Rv getAppVersions(@RequestBody PageDto page) {
        return appVersionService.getAppVersions(page);
    }

    /**
     * 删除指定App版本信息
     *
     * @return
     */
    @ApiOperation(value = "删除指定App版本信息", notes = "删除指定App版本信息")
    @GetMapping(value = "delAppVersion")
    public Rv delAppVersion(String id) {
        return appVersionService.delAppVersion(id);
    }

    /**
     * 获取app版本信息
     *
     * @return
     */
    @ApiOperation(value = "获取app版本信息", notes = "获取app版本信息")
    @GetMapping(value = "getAppVersion")
    public Rv getAppVersion(HttpServletRequest request) {
        String clientId = request.getHeader("clientId");
        String appCode = request.getHeader("appCode");
        return appVersionService.getAppVersion(clientId, appCode);
    }

    /**
     * 获取客服电话
     *
     * @return
     */
    @ApiOperation(value = "获取客服电话", notes = "获取客服电话")
    @GetMapping(value = "getServicePhone")
    public Rv getServicePhone() {
        return appVersionService.getServicePhone();
    }

}
